﻿using CRM.Authorization.Permissions;
using Microsoft.AspNetCore.Authorization;
using System;

namespace CRM.Authorization.Rule
{
    public partial class PermissionAttribute: AuthorizeAttribute
    {
        //System.Enum 或 PermissionAttribute<TEnum> 不可以作为注解使用
        //public PermissionAttribute(Enum @enum)
        //{
        //    Value = @enum;
        //}
        private PermissionAttribute() : base()
        {
        }
        public Enum Enum { get;private set; }
        public string Type { get; private set; }
        public PermissionAttribute(UserManager p) : base(nameof(PermissionAttribute))
        {
            SetData(nameof(UserManager), p);
        }
        public PermissionAttribute(SocialMarketingTasks p) : base(nameof(PermissionAttribute))
        {
            SetData(nameof(SocialMarketingTasks), p);
        }
        public PermissionAttribute(BuyersData p) : base(nameof(PermissionAttribute))
        {
            SetData(nameof(BuyersData), p);
        }     
        public PermissionAttribute(LoggingInfo p) : base(nameof(PermissionAttribute))
        {
            SetData(nameof(LoggingInfo), p);
        }     
        public PermissionAttribute(SystemManager p) : base(nameof(PermissionAttribute))
        {
            SetData(nameof(SystemManager), p);
        }
        private void SetData(string Type,Enum @enum) {
            this.Type = Type;
            Enum = @enum;
        }

    }
}
